package com.crm.dao.mapper.customMapper.cluePoolManagerCustomMapper;

import com.crm.model.entity.cluePoolManager.ClueFollow;
import com.crm.model.qo.cluePoolManager.ClueFollowQO;
import com.crm.model.vo.cluePoolManager.ClueFollowVO;
import com.crm.model.vo.cluePoolManager.ContactDetailFollowVO;
import com.crm.model.vo.contactManager.ContactReportListVO;
import com.crm.model.vo.contactManager.ContactStatisticsVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @ Author ：pym
 * @ Date   ：2021/1/8 12:29
 */
public interface ClueFollowCustomMapper {
    /**
     * 线索池详情-线索清单-跟进记录
     * @param clueId---线索Id
     * @return
     */
    List<ClueFollowVO> selectClueFollowVOList(@Param("clueId") String clueId);

    /**
     * 客户详情-通过客户id查询跟进记录
     * @param clueFollowQO customerId 客户id
     * @param sortOrder 分组信息
     * @return
     */
    List<ClueFollowVO> followVOListByCustomerId(@Param("clueFollowQO") ClueFollowQO clueFollowQO, @Param("sortOrder")String sortOrder);

    /**
     * 用户系统--客户管理>我的客户>跟进记录详情
     * @param clueFollowId ---跟进记录主键
     * @param type 1:单品客户跟进详情
     * @author yincuimei
     * @return
     */
    ClueFollowVO selectClueFollowVOById(@Param("clueFollowId")String clueFollowId, @Param("type")String type, @Param("followWay")Integer followWay);

    /**
     * 联系人详情-跟进记录查询-通过联系人id
     * @param contactId 联系人id
     * @param dateUnit 本周 1 本月 2
     * @return
     */
    List<ContactDetailFollowVO> selectFollowByContactId(@Param("contactId")String contactId, @Param("dateUnit")Integer dateUnit);

    /**
     * 跟进记录
     * @param clueFollowQO
     * @param sortOrder
     * @param dateUnit 1今天 2本周 3本月 4本年
     * @return
     */
    List<ClueFollowVO> selectClueFollowPageList(@Param("qo") ClueFollowQO clueFollowQO, @Param("sortOrder") String sortOrder,@Param("dateUnit") Integer dateUnit);

    List<Integer> getFollowCountByPlanDate(@Param("planDate") String planDate, @Param("accountId")String accountId,@Param("startDate") String startDate,@Param("endDate") String endDate);



    /**
     * @Description: 按天统计时间段内跟进次数
     * @Param: [startTime, endTime]
     * @Return: java.util.List<com.crm.model.vo.contactManager.ContactStatisticsVO>
     * @Author: lixq-f
     * @Date: 2021/4/16
     **/
    List<ContactStatisticsVO> statisticsFollowTimesByDay(@Param("startTime") String startTime,
                                                         @Param("endTime") String endTime,
                                                         @Param("accountId") String accountId);


    /**
     * @Description: 按月统计本年度跟进次数
     * @Param: [startTime, endTime]
     * @Return: java.util.List<com.crm.model.vo.contactManager.ContactStatisticsVO>
     * @Author: lixq-f
     * @Date: 2021/4/16
     **/
    List<ContactStatisticsVO> statisticsFollowTimesByMonth(@Param("thisYear") int thisYear,
                                                           @Param("accountId") String accountId);


    /**
     * 联系人报表列表
     * @param accountId
     * @param startTime
     * @param endTime
     * @return
     */
    List<ContactReportListVO> getContactReportList(@Param("accountId") String accountId,
                                                   @Param("startTime") String startTime,
                                                   @Param("endTime") String endTime);

    /**
     * 单品客户跟进记录
     * @Author pym
     * @Date  2021/5/12 14:25
     * @param order 排序
     * @param singleProductCustomerId 单品客户ID
     * @param accountId 账号ID
     * @return {@link {java.util.List<com.crm.model.vo.cluePoolManager.ClueFollowVO>}}
     */
    List<ClueFollowVO> selectClueFollowListByCustomerId(@Param("order")String order,
                                                        @Param("singleProductCustomerId")String singleProductCustomerId,
                                                        @Param("accountId")String accountId);

    /**
     * 根据是否有跟进记录判断是否可删除
     * @Author renshaorong
     * @Date 2021/5/27 
     * @param cpFollowPlanId
     * @return
     */
    Integer canBeDelete(@Param("cpFollowPlanId") String cpFollowPlanId);


    /**
     * @Description: 批量插入跟进记录
     * @Param: [followList]
     * @Return: java.lang.Integer
     * @Author: lixq-f
     * @Date: 2021/6/8
     **/
    Integer batchInsert(@Param("followList") List<ClueFollow> followList);

    /**
     * 根据创建时间和跟进详情和跟进人id匹配
     * @param createTm
     * @param followDetail
     * @param accountId
     * @return
     */
    ClueFollowVO selectClueFollow(@Param("createTm") String createTm,
                                  @Param("followDetail") String followDetail,
                                  @Param("accountId") String accountId,
                                  @Param("customerId") String customerId);

    List<ClueFollowVO> selectClueFollowWayIsNull();

    /**
     * 通过跟进id查找呼叫表中的通话记录url
     * @Author renshaorong
     * @Date 2021/8/23
     * @param followId
     * @return
     */
    String getCallRecordByFollowId(String followId);
}
